const Koa = require('koa');
const https = require('https')
const fs = require('fs')
// const sslify = require('koa-sslify').default;
const {koaBody} = require('koa-body');
const json = require('koa-json')
//路由:()直接实例化
const router = require('./src/router')
// const path = require("path");
// const websocketServer = require('./src/utils/webSocket')
// const abnormal = require('./src/config/abnormal')
// const {koaSwagger} = require('koa2-swagger-ui')
// console.log(process.env.DB_PASSWORD, 'env')

const app = new Koa();

// app.use(cors());
app.use(json())
app.use(koaBody());
// app.use(abnormal)
// app.use(sslify());

//启动路由
app.use(router.routes())
app.use(router.allowedMethods())

// const swagger = require('./src/utils/swagger')
// app.use(swagger.routes(), swagger.allowedMethods())

// app.use(koaSwagger({
//         routePrefix: '/swagger', // host at /swagger instead of default /docs
//         swaggerOptions: {
//             url: '/swagger.json', // example path to json 其实就是之后swagger-jsdoc生成的文档地址
//         },
//     })
// )

app.listen(5050, () => {
    console.log('服务端在运行')
})

// websocketServer.listen(8080, () => {
//     console.log('websocket在运行')
// })



